import React from 'react';
import base64url from "base64url";
import { connect } from 'dva'
import { routerRedux } from 'dva/router';
import { Icon, List, WhiteSpace, Flex, NoticeBar,Progress,Button} from 'antd-mobile';
import styles from './democraticappraisal.less'



class dreviewDetail extends React.Component {
  constructor(props) {
    super(props);
    this.state = {}
    this.props.dispatch({
      type: 'dreviewLists/fetch',
      payload: {org_code:this.props.location.query.code},
    });
  }
  addPy = () => {
    this.props.dispatch(
      routerRedux.push({
        pathname: "/work/democraticappraisal/addappraisal",
      })
    );
  };

  render() {
    const dreviewList = [];
    const dreviewData = this.props.reviews;
    for (let key in dreviewData) {
      dreviewList.push(dreviewData[key])
    }
    const Item = List.Item;
    const Brief = Item.Brief;

    return (
      <div className="minzhu">

        <div className={styles.bg} style={{width: '97%', height: '3.8rem'}}>
          <div style={{width: '100%'}}>
            <div style={{width: '97%', fontSize: '0.3rem', float: 'left'}}>
              <Icon size="md" style={{verticalAlign: 'sub'}} type={require('../../../svgs/work/shu.svg')}/>
              <span style={{fontSize: '0.41rem'}}>民主评议[2017年10月]</span></div>
          </div>
          <Flex style={{marginTop: '0.9rem', width: '100%'}} justify="center">
            <Flex.Item style={{textAlign: 'center'}}>
              <div style={{fontSize: '0.6rem'}}>12</div>
              <span style={{fontSize: '0.3rem'}}>优秀</span>
            </Flex.Item>
            <Flex.Item style={{textAlign: 'center'}}>
              <div style={{fontSize: '0.6rem'}}>14</div>
              <span style={{fontSize: '0.3rem'}}>合格</span>
            </Flex.Item>
            <Flex.Item style={{textAlign: 'center'}}>
              <div style={{fontSize: '0.6rem'}}>56</div>
              <span style={{fontSize: '0.3rem'}}>基本合格</span>
            </Flex.Item>
          </Flex>
          <Flex style={{marginTop: '0.3rem', width: '100%'}} justify="center">
            <Flex.Item style={{textAlign: 'center'}}>
              <div style={{fontSize: '0.6rem'}}>0</div>
              <span style={{fontSize: '0.3rem'}}>不合格</span>
            </Flex.Item>
            <Flex.Item style={{textAlign: 'center'}}>
              <div style={{fontSize: '0.6rem'}}>3</div>
              <span style={{fontSize: '0.3rem'}}>参加民主生活会</span>
            </Flex.Item>
            <Flex.Item style={{textAlign: 'center'}} onClick={this.addPy}>
              <div className={styles.svg1}><Icon size="lg" type={require('../../../svgs/work/jia.svg')}/></div>
              <span style={{fontSize: '0.3rem'}}>新增评议</span>
            </Flex.Item>
          </Flex>
        </div>

        <WhiteSpace/>
        <NoticeBar icon={<Icon type={require('../../../svgs/work/duoren.svg')}/>}
                   action={<span style={{color: '#a1a1a1'}}>5分钟前</span>}>
          &nbsp;&nbsp;当前组织：{this.props.location.query.name}
        </NoticeBar>
        <WhiteSpace/>
        <div>

          {this.props.reviews &&
          <List className="my-democracy">
            {
              dreviewList.map((it) => {
                return <Item>
                  {it.member ? it.member.name : "没有名字"}
                  <p className={styles.itemP}
                  style={{fontSize: '0.26rem', color: '#B3B3B3'}}>
                  <span>评议结果:{it.appraisalResult}</span>
                  <span>评议年度:{it.year}</span>
                  <span>评议时间:{it.review_time}</span>
                </p>
                </Item>
              })
            }
          </List>
          }
        </div>
      </div>
    )
  }
}
function mapStateToProps({dreviewLists}) {
  if (dreviewLists.data1) {
    return {
      reviews: dreviewLists.data1.data
    }
  }
  else {
    return {}
  }
}
export default connect(mapStateToProps)(dreviewDetail);
